package com.sh.data.engine.domain.dataasset.model.domain;


import lombok.Data;

import java.util.Objects;
import java.util.Set;

@Data
public class TableLineageDomain {

    private Set<TableNode> nodeList;

    private Set<Relation> relationList;

    @Data
    public static class TableNode {

        private Long tblId;

        private String tblName;

        private Integer isOwner;

        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            TableNode tableNode = (TableNode) o;
            return Objects.equals(tblId, tableNode.tblId) &&
                Objects.equals(tblName, tableNode.tblName);
        }

        @Override
        public int hashCode() {
            return Objects.hash(tblId, tblName);
        }
    }


    @Data
    public static class Relation {

        private String sourceTblName;

        private String targetTblName;

        private Long sourceTblId;

        private Long targetTblId;

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            Relation relation = (Relation) o;
            return Objects.equals(sourceTblId, relation.sourceTblId) &&
                Objects.equals(targetTblId, relation.targetTblId);
        }

        @Override
        public int hashCode() {
            return Objects.hash(sourceTblId, targetTblId);
        }
    }

}
